<?php
defined('BY_JYA') or exit('error');
//判断是否存在openid
$result=array();
$after_auth_url=$_SESSION['after_auth_url']?:$_AR['siteurl'];
if($_SESSION['after_auth_url']){
	unset($_SESSION['after_auth_url']);
}
if($_RQ['op']=='base'){
	if($_RQ['isapp']==1){
		$postdata=get_postdata();
	}
	$result=model('core/fans_api')->up_userinfo('base',$_RQ['code'],$postdata);
}
if($_RQ['op']=='info'){
	$result=model('core/fans_api')->up_userinfo('info',$_RQ['code']);
}
if($_RQ['op']=='wxwork'){
	if($_RQ['code']){
		$user_ticket=model('core/wxwork_userapi')->get_worker_user_ticket($_RQ['code']);
	}
	if($user_ticket){
		$info=model('core/wxwork_userapi')->get_worker_info($user_ticket);
	}
	if($info){
		$pid=pdo_getcolumn('core_account_wxwork_app',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_SESSION['wxworkapp_id']),'pid');
	}
	$pluginname=pdo_getcolumn('core_plugins',array('id'=>$pid),'name');
	if($pluginname){
		$pluginname=$pluginname=='jy_merchscrm'?'jy_scrm':$pluginname;
		model($pluginname.'/worker')->upinfo($info);
	}
}
header('location:'.$after_auth_url);
exit ('获取粉丝openid成功！');